{extend name="base"/}
{block name="content"}

<input type="hidden" id="token_user" value="{$token}">
<a id="chooseWXPay" style="font-size:100px" onclick="onBridgeReady()">支付</a>
{include file="public:footer" /}
<script src="__STATIC__/index/js/jquery-1.8.3.min.js"></script>
<script src="__STATIC__/index/js/commonNew.js"></script>
<script src="__STATIC__/index/js/token.js"></script>
<script >
    function onBridgeReady(){
        var id=getUrlParam('id');
        console.log(id);
        var dataD=storage.getItem(id);
        var    dataS=JSON.parse(dataD);
        console.log(dataS);
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest', {
                "appId":"wx49cfc16a07e40442",     //公众号名称，由商户传入
                "timeStamp":dataS.timeStamp,         //时间戳，自1970年以来的秒数
                "nonceStr":dataS.nonceStr, //随机串
                "package":dataS.package,
                "signType":dataS.signType,        //微信签名方式：
                "paySign":dataS.paySign, //微信签名
            },
            function(res){
                if(res.err_msg == "get_brand_wcpay_request:ok" ) {
                    alert('支付成功')
                }     // 使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回    ok，但并不保证它绝对可靠。
            }
        );
    }
    if (typeof WeixinJSBridge == "undefined"){
        if( document.addEventListener ){
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        }else if (document.attachEvent){
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    }else{
        onBridgeReady();
    }
</script>
{/block}

